﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;
using System.Data.SqlClient;

namespace DAO
{
   public class QuyDinhHanDatVeDAO
    {
        Database db;
        SqlConnection sql;
        DataTable dt;
       
     
       

        public QuyDinhHanDatVeDAO()
        {
            db = new Database();
            sql = db.getConnection();
        }
        
        public DataTable LayDSQuyDinhHanDatVe()
        {
            dt = db.Execute("Select * FROM THAMSO ");
            return dt;
        }
       
       public void CapNhat(QuyDinhHanDatVeDTO qdhandatveDTO)
        {
            SqlCommand updatecmd = new SqlCommand("UpdateQDHDV_Proc", sql);
            updatecmd.Connection = sql;
            updatecmd.CommandType = CommandType.StoredProcedure;

            SqlParameter partgchamnhatdatve= new SqlParameter("@tgchamnhatdatve", SqlDbType.Int);
            SqlParameter partgchamnhathuyve = new SqlParameter("@tgchamnhathuyve", SqlDbType.Int);
           
            partgchamnhatdatve.Value = qdhandatveDTO.TGchamnhatdatve;
            partgchamnhathuyve.Value = qdhandatveDTO.TGchamnhathuyve;
            
            updatecmd.Parameters.Add(partgchamnhatdatve);
            updatecmd.Parameters.Add(partgchamnhathuyve);
           
            SqlDataAdapter dataAdapter = new SqlDataAdapter();
            dataAdapter.UpdateCommand = updatecmd;
            sql.Open();
            
            updatecmd.ExecuteNonQuery();
            sql.Close();
        }

        
    }
}
